---------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\Users\sbstjp\OneDrive - Cardiff University\FinalHarvard\Appendix2.4.log
  log type:  text
 opened on:  12 May 2025, 16:36:42

. use "C:\Users\sbstjp\OneDrive - Cardiff University\anes_timeseries_2024_stata_20250219.dta" // ANES 2024 Time
>  Series Study // Preliminary Release: Pre-Election Data February 19, 2025 version

. 
. // Create social justice scale
. * Rename variables 
. rename V241290x Edi 

. rename V241372x Tgbathroom 

. rename V241375x Tgsport 

. rename V241412x Appprotestgaza 

. 
. * Delete missing values
. foreach var in Edi Tgbathroom Tgsport Appprotestgaza {
  2.     replace `var' = . if `var' < 0
  3.     tabulate `var', missing
  4. }
(308 real changes made, 308 to missing)

PRE: SUMMARY Approve/disapprove |
         Diversity, Equity, and |
                Inclusion (DEI) |      Freq.     Percent        Cum.
--------------------------------+-----------------------------------
          1. Favor a great deal |        427       12.75       12.75
     2. Favor a moderate amount |        465       13.88       26.63
              3. Favor a little |        147        4.39       31.02
    4. Neither favor nor oppose |      1,129       33.71       64.74
             5. Oppose a little |         99        2.96       67.69
    6. Oppose a moderate amount |        272        8.12       75.81
         7. Oppose a great deal |        502       14.99       90.80
                              . |        308        9.20      100.00
--------------------------------+-----------------------------------
                          Total |      3,349      100.00
(278 real changes made, 278 to missing)

                  PRE: SUMMARY: |
 Approve/disapprove transgender |
       people use bathroom that |
                     matches ge |      Freq.     Percent        Cum.
--------------------------------+-----------------------------------
          1. Favor a great deal |        486       14.51       14.51
     2. Favor a moderate amount |        274        8.18       22.69
              3. Favor a little |         97        2.90       25.59
    4. Neither favor nor oppose |        744       22.22       47.81
             5. Oppose a little |         75        2.24       50.04
    6. Oppose a moderate amount |        219        6.54       56.58
         7. Oppose a great deal |      1,176       35.11       91.70
                              . |        278        8.30      100.00
--------------------------------+-----------------------------------
                          Total |      3,349      100.00
(277 real changes made, 277 to missing)

     PRE: SUMMARY: Favor/oppose |
 banning transgender girls from |
              K-12 girls sports |      Freq.     Percent        Cum.
--------------------------------+-----------------------------------
          1. Favor a great deal |      1,127       33.65       33.65
     2. Favor a moderate amount |        254        7.58       41.24
              3. Favor a little |         95        2.84       44.07
    4. Neither favor nor oppose |        814       24.31       68.38
             5. Oppose a little |         78        2.33       70.71
    6. Oppose a moderate amount |        243        7.26       77.96
         7. Oppose a great deal |        461       13.77       91.73
                              . |        277        8.27      100.00
--------------------------------+-----------------------------------
                          Total |      3,349      100.00
(288 real changes made, 288 to missing)

    PRE: SUMMARY: Approve/disapprove of |
           protests against war in Gaza |      Freq.     Percent        Cum.
----------------------------------------+-----------------------------------
           1. Approve a lot of protests |        278        8.30        8.30
2. Approve a moderate amount of protest |        298        8.90       17.20
        3. Approve a little of protests |        136        4.06       21.26
4. Neither approve nor disapprove of pr |      1,135       33.89       55.15
     5. Disapprove a little of protests |        129        3.85       59.00
6. Disapprove a moderate amount of prot |        335       10.00       69.01
        7. Disapprove a lot of protests |        750       22.39       91.40
                                      . |        288        8.60      100.00
----------------------------------------+-----------------------------------
                                  Total |      3,349      100.00

. 
. *Reverse coding so social justice values are high
. foreach var in Appprotestgaza Tgbathroom Edi {
  2.     qui sum `var'
  3.     local max_value = r(max)
  4.     gen r`var' = `max_value' + 1 - `var'
  5. }
(288 missing values generated)
(278 missing values generated)
(308 missing values generated)

. 
. *Standardize items in the scale from 1-2 - this avoids 0, for reasons outlined in next step
. foreach var in rEdi rTgbathroom Tgsport rAppprotestgaza {
  2.     summarize `var'
  3.     gen s`var' = 1 + (`var' - r(min)) / (r(max) - r(min))
  4. }

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        rEdi |      3,041    4.068727      1.9484          1          7
(308 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
 rTgbathroom |      3,071    3.368935    2.274272          1          7
(278 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
     Tgsport |      3,072    3.336914    2.217592          1          7
(277 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
rAppprotes~a |      3,061    3.515518    1.924261          1          7
(288 missing values generated)

. 
. *At this point, the scale has a Cronbach's alpha of 0.76. 
. 
. * Replace missing values with 0 for the specified variables - this is necessary as Stata doesn't add up missi
> ng values and means a 0-1 standardization scale isn't feasible as missing values would overlap with the scale
. foreach var in srEdi srTgbathroom sTgsport srAppprotestgaza {
  2.     replace `var' = 0 if missing(`var')
  3. }
(308 real changes made)
(278 real changes made)
(277 real changes made)
(288 real changes made)

. 
. * Initialize the total score and the count of non-zero responses
. gen total_scoreSJV = 0

. gen count_nonzeroSJV = 0

. 
. * Add each variable to the total scale score and count it if non-zero
. foreach var in srEdi srTgbathroom sTgsport srAppprotestgaza  {
  2.     replace total_scoreSJV = total_scoreSJV + `var'
  3.     replace count_nonzeroSJV = count_nonzeroSJV + (`var' != 0)
  4. }
(3,041 real changes made)
(3,041 real changes made)
(3,071 real changes made)
(3,071 real changes made)
(3,072 real changes made)
(3,072 real changes made)
(3,061 real changes made)
(3,061 real changes made)

. 
. * Calculate the average score, avoiding division by zero
. gen SocJusValues = .
(3,349 missing values generated)

. replace SocJusValues = total_scoreSJV / count_nonzeroSJV if count_nonzeroSJV > 0
(3,097 real changes made)

. 
. // Demographics
. *Delete missing values and rename
. rename V241458x age

. replace age=. if age<0 
(175 real changes made, 175 to missing)

. 
. rename V241566x income

. replace income=. if income<0 
(437 real changes made, 437 to missing)

. 
. replace V241177=. if V241177==99 
(542 real changes made, 542 to missing)

. replace V241177=. if V241177<0
(24 real changes made, 24 to missing)

. rename V241177 libconsp

. 
. * Generate dummies
. gen FemaleGender=.
(3,349 missing values generated)

. replace FemaleGender=1 if V241551==1
(1,416 real changes made)

. replace FemaleGender=2 if V241551==2
(1,612 real changes made)

. 
. gen Graduate=.
(3,349 missing values generated)

. replace Graduate=0 if inrange(V241465x, 1, 3)
(1,895 real changes made)

. replace Graduate=1 if inlist(V241465x, 4, 5)
(1,403 real changes made)

. 
. gen BIPOC=.
(3,349 missing values generated)

. replace BIPOC=0 if V241501x==1
(2,301 real changes made)

. replace BIPOC=1 if inrange(V241501x, 2, 6)
(1,001 real changes made)

. 
. // Standardize 
. egen Age = std(age)
(175 missing values generated)

. egen Income = std(income)
(437 missing values generated)

. 
. // Regressions
. regress SocJusValues Age BIPOC FemaleGender Graduate Income [pweight=V240105a], robust
(sum of wgt is 2,794.55341401691)

Linear regression                               Number of obs     =      2,730
                                                F(5, 2724)        =      35.14
                                                Prob > F          =     0.0000
                                                R-squared         =     0.1132
                                                Root MSE          =     .24969

------------------------------------------------------------------------------
             |               Robust
SocJusValues | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
         Age |  -.0417517   .0069893    -5.97   0.000    -.0554565   -.0280469
       BIPOC |   .0556644   .0147253     3.78   0.000     .0267905    .0845382
FemaleGender |   .0538449   .0135833     3.96   0.000     .0272103    .0804796
    Graduate |   .1535645   .0156476     9.81   0.000     .1228822    .1842468
      Income |  -.0195422   .0073681    -2.65   0.008    -.0339899   -.0050945
       _cons |   1.269916   .0226115    56.16   0.000     1.225578    1.314253
------------------------------------------------------------------------------

. eststo
(est1 stored)

. regress SocJusValues Age BIPOC FemaleGender Graduate Income if libconsp < 4 [pweight=V240105a], robust  
(sum of wgt is 746.2347037518043)

Linear regression                               Number of obs     =        791
                                                F(5, 785)         =       6.74
                                                Prob > F          =     0.0000
                                                R-squared         =     0.0629
                                                Root MSE          =     .20707

------------------------------------------------------------------------------
             |               Robust
SocJusValues | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
         Age |  -.0292376   .0103377    -2.83   0.005    -.0495305   -.0089447
       BIPOC |   -.048813   .0239449    -2.04   0.042    -.0958166   -.0018093
FemaleGender |  -.0027784   .0209464    -0.13   0.895    -.0438959    .0383391
    Graduate |   .0775759   .0245442     3.16   0.002     .0293957     .125756
      Income |    .007954   .0127662     0.62   0.533    -.0171058    .0330139
       _cons |   1.637043   .0396881    41.25   0.000     1.559135     1.71495
------------------------------------------------------------------------------

. eststo
(est2 stored)

. esttab

--------------------------------------------
                      (1)             (2)   
             SocJusValues    SocJusValues   
--------------------------------------------
Age               -0.0418***      -0.0292** 
                  (-5.97)         (-2.83)   

BIPOC              0.0557***      -0.0488*  
                   (3.78)         (-2.04)   

FemaleGender       0.0538***     -0.00278   
                   (3.96)         (-0.13)   

Graduate            0.154***       0.0776** 
                   (9.81)          (3.16)   

Income            -0.0195**       0.00795   
                  (-2.65)          (0.62)   

_cons               1.270***        1.637***
                  (56.16)         (41.25)   
--------------------------------------------
N                    2730             791   
--------------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

. 
. log close
      name:  <unnamed>
       log:  C:\Users\sbstjp\OneDrive - Cardiff University\FinalHarvard\Appendix2.4.log
  log type:  text
 closed on:  12 May 2025, 16:36:52
---------------------------------------------------------------------------------------------------------------
